package com.hl.card.modular.packBack.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hl.card.common.persistence.dao.MarketingManageMapper;
import com.hl.card.common.persistence.model.MarketingManage;
import com.hl.card.modular.packBack.service.IMarketingManageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 营销管理 服务实现类
 * </p>
 *
 * @author huangpu
 * @since 2018-06-07
 */
@Service
public class MarketingManageServiceImpl extends ServiceImpl<MarketingManageMapper, MarketingManage> implements IMarketingManageService {
	
	@Resource(name="marketingManageMapper")
	private MarketingManageMapper marketingManageMapper;

	@Override
	public MarketingManage selectMarketing() {
		MarketingManage marketingManage = marketingManageMapper.selectMarketing();
		return marketingManage;
	}

	@Override
	public Object RecordIntegral(Integer id) {
		MarketingManage marketingManage = marketingManageMapper.selectId(id);
		 Map<String,Object> map = new HashMap<>();
	        if(marketingManage == null){
	            map.put("code",201);
	            map.put("msg","id不存在");
	            return  map;
	        }
	        BigDecimal fractionAmount;
	        if(marketingManage.getContinuous() == 0){
	            fractionAmount = new BigDecimal(marketingManage.getFirstday()+1).setScale(0) ;
	        }
		return null;
	}
/**
 * 开启是否每日连续签到
 */
	@Override
	public Object seletOfMarketing() {
		 Map<String,Object> map = new HashMap<>();
		 MarketingManage marketingManage = marketingManageMapper.seletOfMarketing();
		 if(marketingManage == null){
	            map.put("code",201);
	            map.put("msg","每日签到联想状态不存在");
	            return  map;
	        }
	        BigDecimal ContinuousCheck1;
	        BigDecimal ContinuousCheck5 = null;
	        BigDecimal ContinuousCheck10 = null;
	        if(marketingManage.getContinuous()==0) {
	        	ContinuousCheck1 = new BigDecimal(marketingManage.getFirstday());
	        }else {
	        	ContinuousCheck1 = new BigDecimal(marketingManage.getFirstday());
	        	ContinuousCheck5 = new BigDecimal(marketingManage.getConFiveDay());
	        	ContinuousCheck10 = new BigDecimal(marketingManage.getConTenDay());
			}
	   //     Integer firstday = marketingManage.getFirstday();
	   //     Integer conFiveDay =  marketingManage.getConFiveDay();
	   //     Integer conTenDay = marketingManage.getConTenDay();
	        map.put("code",200);
	        map.put("firstday",ContinuousCheck1);//为1天
	        map.put("conFiveDay",ContinuousCheck5);//为5天
	        map.put("conTenDay",ContinuousCheck10);//为10天
		return map;
	}
	


}
